/*
 * @Author: HuRrongChao 1556810922@qq.com
 * @Date: 2024-10-08 17:02:40
 * @LastEditors: HuRrongChao
 * @LastEditTime: 2025-04-18 17:06:51
 */
// 用户数据相关配置
import { getItem, setItem, removeItem } from '@/utils/storage.js'

export default {
  namespaced: true,
  // 准备actions--用于响应组件中的动作
  actions: {
  },
  // mutations--用于操作数据state
  mutations: {
    CHANGE_DIALOG_STATE(state) {
      state.isShowLogin = !state.isShowLogin
    },
    SET_USER_ID(state, user_id) {
      state.user_id = user_id
    },
    SET_SCHOOL_CODE(state, school_code) {
      state.school_code = school_code
    },
    SET_SCHOOL_NAME(state, school_name) {
      state.school_name = school_name
    },
    SET_TOKEN(state, token) {
      state.token = token
      removeItem('Refresh_token')
      setItem('token', token)
    },
    SET_REFRESH_TOKEN(state, token) {
      state.token = token
      removeItem('token')
      setItem('Refresh_token', token)
    }
  },
  // 准备state--用于存储数据
  state: {
    isLogin: false,
    isShowLogin: true,
    user_id: null, // 先设置1，代表网友
    // user_id: null,
    school_code: '11847',
    school_name: '佛山大学',
    author_name: null,
    avatar_url: null,
    token: getItem('token') || getItem('Refresh_token')
  }
}